package com.xuhuan.practice.utils;

/**
 * @author: huan.xu
 * @create: 2024/6/10 22:44
 * @description: ThreadLocal工具类
 **/
public class ThreadLocalUtil {

  private ThreadLocalUtil() {
  }

  private static final ThreadLocal THREAD_LOCAL = new ThreadLocal();

  /**
   * 获取数据
   *
   * @param <T>
   * @return
   */
  public static <T> T get() {
    return (T) THREAD_LOCAL.get();
  }

  /**
   * 设置属性
   *
   * @param value
   */
  public static void set(Object value) {
    THREAD_LOCAL.set(value);
  }

  /**
   * 清除ThreadLocal
   */
  public static void remove() {
    THREAD_LOCAL.remove();
  }

}
